package com.yulongtian.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yulongtian.entity.DeviceInfo;
import com.yulongtian.service.DeviceInfoService;
import com.yulongtian.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yulongtian
 * @since 2022-11-15
 */
@RestController
@RequestMapping("/deviceInfo")
@Api(tags = "所有设备的信息")
public class DeviceInfoController {

    @Autowired
    private DeviceInfoService deviceInfoService;

    /**
     * 返回所有的设备编号
     *
     * @return
     */
    @GetMapping("/getDeviceCodeList")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "返回所有的设备编号", notes = "无需传参")
    public R getDeviceCodeList() {
        List<String> res = deviceInfoService.getDeviceCodeList();
        return R.ok().data("data", res);
    }


    /**
     * 根据设备编号查询详细信息
     *
     * @param deviceCode 设备编号
     * @return
     */
    @GetMapping("/getDetailInfoByCode")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "根据设备编号查询详细信息", notes = "传入设备编号deviceCode")
    public R getDetailInfoByCode(String deviceCode) {
        DeviceInfo deviceInfo = deviceInfoService.getDetailInfoByCode(deviceCode);
        return R.ok().data("data",deviceInfo);
    }


}

